﻿using System;
using System.Collections.Generic;
using UnityEngine;

namespace H
{
	// Token: 0x0200025C RID: 604
	internal class H_State_Extract : H_State
	{
		// Token: 0x06000FF3 RID: 4083 RVA: 0x00066920 File Offset: 0x00064B20
		public H_State_Extract(H_Members members) : base(members)
		{
		}

		// Token: 0x06000FF4 RID: 4084 RVA: 0x0006692C File Offset: 0x00064B2C
		public override void In(H_State.Message msg)
		{
			this.members.PlayAnime("Extract", 0.2f);
			this.extractDelay = 2f;
			this.timer = 0f;
			this.extracted = false;
			this.members.EnableTinIK = false;
		}

		// Token: 0x06000FF5 RID: 4085 RVA: 0x0006696C File Offset: 0x00064B6C
		public override void Main()
		{
			this.timer += Time.deltaTime;
			if (!this.extracted)
			{
				if (this.timer >= this.extractDelay)
				{
					this.Extract();
				}
			}
			else if (this.members.CheckEndAnime("Extract"))
			{
				this.Next();
			}
		}

		// Token: 0x06000FF6 RID: 4086 RVA: 0x000669D0 File Offset: 0x00064BD0
		private void Extract()
		{
			H_Expression.TYPE type = H_Expression.TYPE.EXTRACT;
			H_StyleData style = this.members.param.style;
			if ((style.detailFlag & 4) != 0)
			{
				type = H_Expression.TYPE.EXTRACT_FELLATIO;
			}
			else if ((style.detailFlag & 8) != 0)
			{
				type = H_Expression.TYPE.EXTRACT_IRRUMATIO;
			}
			this.members.param.mouth = H_MOUTH.FREE;
			this.members.Expression(type);
			bool flag = (style.detailFlag & 16) != 0;
			bool flag2 = (style.detailFlag & 32) != 0;
			List<Female> females = this.members.GetFemales();
			for (int i = 0; i < females.Count; i++)
			{
				bool flag3 = false;
				if (females[i].personality.spermInCntV > 0 && flag)
				{
					females[i].personality.spermInCntV = 0;
					females[i].dripParticleVagina.Play();
					flag3 = true;
				}
				if (females[i].personality.spermInCntA > 0 && flag2)
				{
					females[i].personality.spermInCntA = 0;
					females[i].dripParticleAnus.Play();
					flag3 = true;
				}
				if (flag3)
				{
					this.members.VoiceExpression(i, H_Voice.TYPE.FALL_LIQUID);
				}
			}
			this.extracted = true;
		}

		// Token: 0x06000FF7 RID: 4087 RVA: 0x00066B30 File Offset: 0x00064D30
		private void Next()
		{
			if (this.members.StyleData.type == H_StyleData.TYPE.SERVICE && this.members.StyleData.IsInMouth())
			{
				Female female = this.members.GetFemale(0);
				Personality personality = this.members.GetFemale(0).personality;
				if (personality.likeFeratio)
				{
					base.ChangeState(H_STATE.SHOW_MOUTH_LIQUID);
				}
				else
				{
					bool flag;
					if (!female.IsFloped())
					{
						flag = (UnityEngine.Random.Range(0f, 1f) <= 0.7f);
					}
					else
					{
						flag = (UnityEngine.Random.Range(0f, 1f) <= 0.3f);
					}
					if (flag)
					{
						base.ChangeState(H_STATE.COUGH);
					}
					else
					{
						base.ChangeState(H_STATE.EXTRACTED_WAIT);
					}
				}
			}
			else
			{
				base.ChangeState(H_STATE.EXTRACTED_WAIT);
			}
		}

		// Token: 0x06000FF8 RID: 4088 RVA: 0x00066C10 File Offset: 0x00064E10
		public override void Out()
		{
		}

		// Token: 0x04001157 RID: 4439
		private float timer;

		// Token: 0x04001158 RID: 4440
		private bool extracted;

		// Token: 0x04001159 RID: 4441
		private float extractDelay;
	}
}
